﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.SqlClient;
namespace DataAccess_Layer
{
    public class TinTucNCC_DAC
    {
        DataClasses_RetailerDataContext context = DataAccessHelper.DB;
        public void Insert(TinTucNCC x)
        {
            try
            {
                context.TinTucNCCs.InsertOnSubmit(x);
                DataAccessHelper.Save();
            }
            catch(Exception e)
            {
            }

        }
        public TinTucNCC get(int id)
        {
            TinTucNCC c = new TinTucNCC();
            var data = from p in context.TinTucNCCs
                       where p.ID==id
                       select p;
            foreach (TinTucNCC x in data)
            {
                c.ID = x.ID;
                c.TenNCC = x.TenNCC;
                c.NgayDangTin = x.NgayDangTin;
                c.Hinh = x.Hinh;
                c.TieuDe = x.TieuDe;
                c.NoiDung = x.NoiDung;
            }
            return c;
        }
    }
}
